package com.netty.esc.config.websocket;

import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.CommandLineRunner;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import javax.annotation.Resource;

/**
 * @Author: zhaoyang
 * @Data: 2022/3/20 21:41
 * @Description
 * 任务调度类
 */

@Component
@Slf4j
@Order(value = 10)
//public class WebTimeHandler  implements ApplicationRunner {
public class WebTimeHandler  implements CommandLineRunner {

    @Resource
    WebSocketServer webSocketServer;


    /**
     * @PostConstruct方法会因为线程阻塞而导致JVM无法完全启动
     * */

    @PostConstruct
    public void asd(){
        System.out.println("post");
    }

    @PreDestroy
    public void weq(){
        System.out.println("pre");

    }

    public WebTimeHandler(){
        System.out.println("构造器");
    }


//    @Override
//    public void run(ApplicationArguments args) throws Exception {
//        webSocketServer.start();
//    }

    @Override
    public void run(String... args) throws Exception {
        webSocketServer.start();
    }
}
